package org.xy.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.xy.bean.Student;

@Component("studentDAO")
public class StudentDAO extends BasicDAO {

	@Autowired(required = false)
	@Qualifier("studentA")
	private Student student;

	public void insertDefault() {

		String std_sql = "insert into student(id,name,age,sch_id) values("
				+ this.student.getId() + ",'" + this.student.getName() + "',"
				+ this.student.getAge() + ","
				+ this.student.getSchool().getId() + ")";
		this.logger.info("Execute SQL:" + std_sql);
		this.jdbcTemplate.execute(std_sql);

	}

	public void insert(Student student) {

		String std_sql = "insert into student(id,name,age,sch_id) values("
				+ student.getId() + ",'" + student.getName() + "',"
				+ student.getAge() + "," + student.getSchool().getId() + ")";
		this.logger.info("Execute SQL:" + std_sql);
		this.jdbcTemplate.execute(std_sql);

	}

}
